package mufanPoint;

import java.util.*;

public class searchString {

	//data為資料庫抓到的每筆資料，keyWord為使用者輸入的關鍵字
    public searchString(String data, String keyWord) {
    }

    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);

        String keyWord;
        String data="abby hong";
        int count=0;

        System.out.print("請輸入搜尋字串");
        keyWord=input.next();

        if(keyWord.length()==1){
			for(int i=0;i<data.length();i++){
				if(keyWord.charAt(0)== data.charAt(i))
					System.out.print("get result!");
				}
        	}

        else if(keyWord.length()<data.length()){
        for(int i=0;i<data.length();i++){
        	for(int j=0;j<keyWord.length();j++){
        		char a=data.charAt(i+j);
        		char b=keyWord.charAt(j);
        		if(a==b){
        		count++;
        		}
        		else if(count==keyWord.length()){
        			break;
        		}
        			else{
        			count=0;
        			break;
        			}
        		}
        	}
        	if(count==keyWord.length())
			System.out.print("get result!!");
        }

        else if(keyWord.length()==data.length()){
        	if(keyWord.equals(data))
        		System.out.print("get result!");
        	}
    }
}